#pragma once

class Vector3 {
public:
    Vector3() {}
    Vector3(double x1, double x2, double x3);

    int size() const { return 3; }

    double  operator()(int i) const { return _x[i]; }
    double& operator()(int i)       { return _x[i]; }

private:
    double _x[3];
};

inline Vector3::Vector3(double x1, double x2, double x3) {
    _x[0] = x1;
    _x[1] = x2;
    _x[2] = x3;
}

// Returns the dot product between two 3-length vectors.
inline double dot(const Vector3 &a, const Vector3& b) {
    return a(0)*b(0) + a(1)*b(1) + a(2)*b(2);
};

template<class ostream, class V> 
ostream& operator<<(ostream& o, const V &x) {
    if (x.size() == 0) {
        o << "()";
        return o;
    }
    o << "(" << x(0);
    for (int i=1; i<x.size(); ++i) 
        o << ", " << x(i);
    o << ")";
}

